<?php 

?>
<div class='row-fluid'>
	<div class='span12'>
		<div class="tabbable">
			<ul class="nav nav-tabs" id="site_page_tabs">
				<li class='active' >
					<a data-toggle="tab" href="#individual">
						<?php  echo translate_word_shop('individual_person',$dictionary_app); ?>
					</a>
				</li>
				<li class='' >
					<a data-toggle="tab" href="#legal" id='stocks_head_tab'>
						<?php  echo translate_word_shop('legal_person',$dictionary_app); ?>
					</a>
				</li>
			</ul>
			<div class="tab-content" style='height:100%'>
				<div id='individual' class="tab-pane active" style='height:100%;overflow:hidden' >
					<button class='btn btn-primary btn-success' onclick='open_add(0)'>+ <?php  echo ucfirst(translate_word_shop('add',$dictionary_app)); ?></button>
					<table id="individual_table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>	
								<th><?php  echo translate_word_shop('name',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('email',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('telephone',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('city',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('Actions',$dictionary_app); ?></th>
							</tr>
						</thead>
						<tbody>
							<?php 
							$results=$shopObj->fetch_result("SELECT * FROM clients WHERE type=0");
							foreach ($results as $key => $value) {
										
								$city = $shopObj->fetch_one("SELECT name FROM cities WHERE id='{$value['city_id']}'");

								echo "<tr>
											<td>{$value['name']}</td>
											<td>{$value['email']}</td>
											<td>{$value['phone']}</td>
											<td>{$city['name']}</td>
											<td> 
												<a class='green' href='javascript:void(0)' onclick='edit_client({$value['id']})'>
													<i class='icon-pencil bigger-130'></i>
												</a>
												<a class='red' href='javascript:void(0)' onclick='delete_client({$value['id']},this,0)'>
													<i class='icon-trash bigger-130'></i>
												</a>
											</td>
										</tr>";
							}
							?>
						</tbody>
					</table>
				</div>
				<div id='legal' class="tab-pane " style='height:100%;overflow:hidden' >
					<button class='btn btn-primary btn-success' onclick='open_add(1)'>+ <?php  echo ucfirst(translate_word_shop('add',$dictionary_app)); ?></button>
					<table id="legal_table" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>	
								<th><?php  echo translate_word_shop('company',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('unique_code',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('email',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('telephone',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('city',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('discount_type',$dictionary_app); ?></th>
								<th><?php  echo translate_word_shop('Actions',$dictionary_app); ?></th>
							</tr>
						</thead>
						<tbody>
							<?php 
							$results=$shopObj->fetch_result("SELECT * FROM clients WHERE type=1");

							foreach ($results as $key => $value) {
								$time = microtime(false);
								$time= explode(' ', $time);
								$discount= $shopObj->fetch_one("SELECT discount FROM discounts WHERE client_id='{$value['id']}' AND active='1' AND `start`<={$time[1]} AND `end`>={$time[1]} ");
								if($discount['discount']==''){
									$disc= '0 %';
								}else{
									$disc= $discount['discount'].' %';
								}

								$city = $shopObj->fetch_one("SELECT name FROM cities WHERE id='{$value['city_id']}'");

								echo "<tr>
								<td>{$value['name']}</td>
								<td>{$value['unique_code']}</td>											
								<td>{$value['email']}</td>
								<td>{$value['phone']}</td>
								<td>{$city['name']}</td>
								<td>{$disc}</td>
								<td> 
								<a class='green' href='javascript:void(0)' onclick='edit_client({$value['id']})'>
								<i class='icon-pencil bigger-130'></i>
								</a>
								<a class='red' href='javascript:void(0)' onclick='delete_client({$value['id']},this,1)'>
								<i class='icon-trash bigger-130'></i>
								</a>
								</td>
								</tr>";
							}
							?>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<div id="modal-clients-data" class="modal hide fade"  tabindex="-1">
		<div class="modal-header no-padding">
			<div class="table-header">
				<button type="button" class="close" data-dismiss="modal">&times;</button>
				<?php  echo translate_word_shop('client_data',$dictionary_app); ?>

			</div>
		</div>
		<div class="tabbable">
			<ul class="nav nav-tabs" id="clients_tabs">
				<li class='active' >
					<a data-toggle="tab" href="#details">
						<?php  echo translate_word_shop('details',$dictionary_app); ?>
					</a>
				</li>
				<li class='' >
					<a data-toggle="tab" href="#orders_history" id='stocks_head_tab'>
						<?php  echo translate_word_shop('orders_history',$dictionary_app); ?>
					</a>
				</li>
				<li class='' >
					<a data-toggle="tab" href="#change_password" id='stocks_head_tab'>
						<?php  echo translate_word_shop('change_password',$dictionary_app); ?>
					</a>
				</li>
			</ul>
			<form id='client_form'>
				<div class="tab-content" style='overflow:auto;height:400px'>

					<div id='details' class="tab-pane active"   >
						<div class="control-group ">
							<label class="control-label span3" for="name"><?php  echo translate_word_shop('firstname_surname',$dictionary_app); ?></label>
							<div class="controls span9">
								<input id="name" name='name' class='span7' type="text" placeholder="" >
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="email"><?php  echo translate_word_shop('email',$dictionary_app); ?></label>
							<div class="controls span9">
								<input id="email" name='email' class='span7' type="email" placeholder="" >
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="email"><?php  echo translate_word_shop('address',$dictionary_app); ?></label>
							<div class="controls span9">
								<textarea name='address' id='address'></textarea>
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="country"><?php  echo translate_word_shop('country',$dictionary_app); ?></label>
							<div class="controls span9">
								<select id='country' class='chosen-select'   name='country'>
									<?php
									$results=$shopObj->fetch_result("SELECT * FROM  countries");
									foreach ($results as $key => $value) {
										echo "<option value='{$value['id']}'>{$value['name']}</option>";
									}
									?>
								</select>
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="county"><?php  echo translate_word_shop('county',$dictionary_app); ?></label>
							<div class="controls span9">
								<select id='county' class='chosen-select' name='county'>
									<?php 
									$results=$shopObj->fetch_result("SELECT * FROM  counties");
									foreach ($results as $key => $value) {
										echo "<option value='{$value['id']}'>{$value['name']}</option>";
									}
									?>
								</select>
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="city"><?php  echo translate_word_shop('city',$dictionary_app); ?></label>
							<div class="controls span9">
								<select id='city' class='chosen-select' name='city'>
									<?php 
									$results=$shopObj->fetch_result("SELECT * FROM  cities");
									foreach ($results as $key => $value) {
										echo "<option value='{$value['id']}'>{$value['name']}</option>";
									}
									?>
								</select>
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="zip_code"><?php  echo translate_word_shop('zip_code',$dictionary_app); ?></label>
							<div class="controls span9">
								<input id="zip_code" name='zip_code' class='span7' type="text" placeholder="" >
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="phone"><?php  echo translate_word_shop('phone',$dictionary_app); ?></label>
							<div class="controls span9">
								<input id="phone" name='phone' class='span7' type="text" placeholder="" >
							</div>
						</div>

						<div class="control-group ">
							<label class="control-label span3" for="terms_and_conditions"><?php  echo translate_word_shop('terms_and_conditions',$dictionary_app); ?></label>
							<div class="controls span9">
								<input  name='terms_and_conditions' class='span5' type="radio" value='1'  >
								<span class='lbl'><?php  echo translate_word_shop('yes',$dictionary_app); ?></span>
								<input  name='terms_and_conditions' class='span5' type="radio" value='0'  >
								<span class='lbl'><?php  echo translate_word_shop('no',$dictionary_app); ?></span>
							</div>
						</div>
						<div id='legal_inputs'  class='span12' style='margin-left:0px;'>
							<div class="control-group ">
								<label class="control-label span3" for="company_contact_name"><?php  echo translate_word_shop('company_name',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="company_contact_name" name='company_contact_name' class='span7' type="text" placeholder="" >
								</div>
							</div>
							<div class="control-group ">
								<label class="control-label span3" for="fax"><?php  echo translate_word_shop('fax',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="fax" name='fax' class='span7' type="text" placeholder="" >
								</div>
							</div>
							<div class="control-group ">
								<label class="control-label span3" for="registration_number"><?php  echo translate_word_shop('registration_number',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="registration_number" name='registration_number' class='span7' type="text" placeholder="" >
								</div>
							</div>
							<div class="control-group ">
								<label class="control-label span3" for="unique_code"><?php  echo translate_word_shop('unique_code',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="unique_code" name='unique_code' class='span7' type="text" placeholder="" >
								</div>
							</div>
							<div class="control-group ">
								<label class="control-label span3" for="bank_name"><?php  echo translate_word_shop('bank_name',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="bank_name" name='bank_name' class='span7' type="text" placeholder="" >
								</div>
							</div>
							<div class="control-group ">
								<label class="control-label span3" for="bank_account"><?php  echo translate_word_shop('bank_account',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="bank_account" name='bank_account' class='span7' type="text" placeholder="" >
								</div>
							</div>
							<div class="control-group ">
								<label class="control-label span3" for="company_phone"><?php  echo translate_word_shop('company_phone',$dictionary_app); ?></label>
								<div class="controls span9">
									<input id="company_phone" name='company_phone' class='span7' type="text" placeholder="" >
								</div>
							</div>
						</div>
					</div>
					<div id='orders_history' class="tab-pane">
						<table id="order_history_table" class="table table-striped table-bordered table-hover">
							<thead>
								<tr>	
									<th><?php  echo translate_word_shop('bill_nr',$dictionary_app); ?></th>
									<th><?php  echo translate_word_shop('date',$dictionary_app); ?></th>
									<th><?php  echo translate_word_shop('status',$dictionary_app); ?></th>
									<th><?php  echo translate_word_shop('see_details',$dictionary_app); ?></th>								
								</tr>
							</thead>
							<tbody>

							</tbody>
						</table>
					</div>
					<div id='change_password' class="tab-pane">
						<div class="control-group ">
							<label class="control-label span3" for="password"><?php  echo translate_word_shop('password',$dictionary_app); ?></label>
							<div class="controls span9">
								<input id="password_client" name='password' class='span7' type="password"  >
							</div>
						</div>
						<div class="control-group ">
							<label class="control-label span3" for="password_repeat"><?php  echo translate_word_shop('repeat_password',$dictionary_app); ?></label>
							<div class="controls span9">
								<input id="password_repeat" name='password_repeat' class='span7' type="password"  >
							</div>
						</div>
					</div>
				</div>

			</div>
		</form>
		<div class="modal-footer ">
			<button class="btn btn-small btn-primary" data-dismiss="modal" onclick='save_client();' ><?php  echo translate_word_shop('save',$dictionary_app); ?></button>
			<button class="btn btn-small btn-danger btn-primary" data-dismiss="modal"><?php  echo translate_word_shop('cancel',$dictionary_app); ?></button>
		</div>
	</div>			
	
</div>